﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Data;
using DevExpress.XtraEditors;

namespace VietKinsNutrition.Data
{
    public class ClsBindingBLL : ClsConnection
    {
        public void Bin_DtGriew(DataGridView Grid, string NamePrc)
        {
            DataSet Dset = new DataSet();
            DataTable NewTable = new DataTable();

            NewTable.TableName = "tblDm_Tinh";
            DataColumn Columm = new DataColumn();
            Columm.ColumnName = Columm.Caption = "STT";
            Columm.DataType = System.Type.GetType("System.Int32");
            Columm.AllowDBNull = false;
            Columm.AutoIncrement = true;
            Columm.AutoIncrementSeed = Columm.AutoIncrementStep = 1;
            NewTable.Columns.Add(Columm);
            OleDBSelectAll(NamePrc).Fill(Dset);
            Grid.DataSource = Dset.Tables[0];
        }

        public bool CheckNullTextbox(TextEdit Textbox)
        {
            return this.ClsEventsInControlbll.CheckNull(Textbox);
        }

        public bool CheckNullCombobox(ComboBoxEdit Cbo)
        {
            return this.ClsEventsInControlbll.CheckNullCombobox(Cbo);
        }

        public BindingSource BingSource(string NamePrc, string NameTable)
        {
            DataSet Dset = new DataSet();
            DataTable NewTable = new DataTable();
            NewTable.TableName = NameTable;
            DataColumn Columm = new DataColumn();
            Columm.ColumnName = Columm.Caption = "STT";
            Columm.DataType = System.Type.GetType("System.Int32");
            Columm.AllowDBNull = false;
            Columm.AutoIncrement = true;
            Columm.AutoIncrementSeed = Columm.AutoIncrementStep = 1;
            NewTable.Columns.Add(Columm);
            Dset.Tables.Add(NewTable);
            OleDBSelectAll(NamePrc).Fill(Dset.Tables[NameTable]);

            BindingSource Bingdin = new BindingSource(Dset, Dset.Tables[0].TableName.ToString());
            return Bingdin;
        }

        public BindingSource BingSourceCombobox(string NamePrc, string NameTable)
        {
            DataSet Dset = new DataSet();
            DataTable NewTable = new DataTable();
            NewTable.TableName = NameTable;
            Dset.Tables.Add(NewTable);
            OleDBSelectAll(NamePrc).Fill(Dset.Tables[NameTable]);

            BindingSource Bingdin = new BindingSource(Dset, NameTable);
            return Bingdin;
        }

        ClsEventsInControlBLL ClsEventsInControlbll = new ClsEventsInControlBLL();

        public void EnableButtonAll(SimpleButton Add, SimpleButton Edit, SimpleButton Del, SimpleButton App, SimpleButton Cancel)
        {
            ClsEventsInControlbll.EnableButtonAll(Add, Edit, Del, App, Cancel);
        }

        public void EnableButton(SimpleButton Add, SimpleButton Edit, SimpleButton App, SimpleButton Cancel)
        {
            ClsEventsInControlbll.EnableButton(Add, Edit, App, Cancel);
        }
    }
}
